package com.csmz.web.controller.enterprise;

import com.csmz.common.annotation.Log;
import com.csmz.common.core.controller.BaseController;
import com.csmz.common.core.domain.AjaxResult;
import com.csmz.common.core.page.TableDataInfo;
import com.csmz.common.enums.BusinessType;
import com.csmz.common.utils.poi.ExcelUtil;
import com.csmz.enterprise.domain.CsmzParttimeRegistrationPerson;
import com.csmz.enterprise.service.ICsmzParttimeRegistrationPersonService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 报名人员Controller
 * 
 * @author TT
 * @date 2025-09-17
 */
@RestController
@RequestMapping("/enterprise/registrationPerson")
public class CsmzParttimeRegistrationPersonController extends BaseController
{
    @Autowired
    private ICsmzParttimeRegistrationPersonService csmzParttimeRegistrationPersonService;

    /**
     * 查询报名人员列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:registrationPerson:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsmzParttimeRegistrationPerson csmzParttimeRegistrationPerson)
    {
        startPage();
        List<CsmzParttimeRegistrationPerson> list = csmzParttimeRegistrationPersonService.selectCsmzParttimeRegistrationPersonList(csmzParttimeRegistrationPerson);
        return getDataTable(list);
    }

    /**
     *  查询我的兼职
     * @param csmzParttimeRegistrationPerson 报名人员
     * @return  结果
     */
    @PreAuthorize("@ss.hasPermi('enterprise:registrationPerson:myParttimeList')")
    @GetMapping("/myParttimeList")
    public TableDataInfo myParttimeList(CsmzParttimeRegistrationPerson csmzParttimeRegistrationPerson)
    {
        startPage();
        List<CsmzParttimeRegistrationPerson> list = csmzParttimeRegistrationPersonService.selectCsmzMyParttimeList(csmzParttimeRegistrationPerson);
        return getDataTable(list);
    }

    /**
     * 导出报名人员列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:registrationPerson:export')")
    @Log(title = "报名人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsmzParttimeRegistrationPerson csmzParttimeRegistrationPerson)
    {
        List<CsmzParttimeRegistrationPerson> list = csmzParttimeRegistrationPersonService.selectCsmzParttimeRegistrationPersonList(csmzParttimeRegistrationPerson);
        ExcelUtil<CsmzParttimeRegistrationPerson> util = new ExcelUtil<CsmzParttimeRegistrationPerson>(CsmzParttimeRegistrationPerson.class);
        util.exportExcel(response, list, "报名人员数据");
    }

    /**
     * 获取报名人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:registrationPerson:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(csmzParttimeRegistrationPersonService.selectCsmzParttimeRegistrationPersonById(id));
    }

    /**
     * 新增报名人员
     */
    @PreAuthorize("@ss.hasPermi('enterprise:registrationPerson:add')")
    @Log(title = "报名人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsmzParttimeRegistrationPerson csmzParttimeRegistrationPerson)
    {
        return success(csmzParttimeRegistrationPersonService.insertCsmzParttimeRegistrationPerson(csmzParttimeRegistrationPerson));
    }

    /**
     * 修改报名人员
     */
    @PreAuthorize("@ss.hasPermi('enterprise:registrationPerson:edit')")
    @Log(title = "报名人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsmzParttimeRegistrationPerson csmzParttimeRegistrationPerson)
    {
        return toAjax(csmzParttimeRegistrationPersonService.updateCsmzParttimeRegistrationPerson(csmzParttimeRegistrationPerson));
    }

    /**
     * 删除报名人员
     */
    @PreAuthorize("@ss.hasPermi('enterprise:registrationPerson:remove')")
    @Log(title = "报名人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(csmzParttimeRegistrationPersonService.deleteCsmzParttimeRegistrationPersonByIds(ids));
    }
}
